unit OperateLog;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, ExtCtrls, Grids, DBGrids, ComCtrls, StdCtrls,
  Buttons, DBCtrls, Mask;

type
  TfrmOperateLog = class(TForm)
    Panel1: TPanel;
    qryOperateLog: TADOQuery;
    dsOperateLog: TDataSource;
    StatusBar1: TStatusBar;
    Panel2: TPanel;
    Label1: TLabel;
    edtName: TEdit;
    Label2: TLabel;
    dtpBegin: TDateTimePicker;
    dtpEnd: TDateTimePicker;
    Label3: TLabel;
    btnSearch: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Panel3: TPanel;
    Label4: TLabel;
    Shape1: TShape;
    Shape2: TShape;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    DBNavigator1: TDBNavigator;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBRichEdit1: TDBRichEdit;
    Label9: TLabel;
    DBEdit4: TDBEdit;
    dbgrdOperateLog: TDBGrid;
    procedure SpeedButton3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure btnSearchClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmOperateLog: TfrmOperateLog;

implementation

uses Main, DataModule;



{$R *.dfm}

procedure TfrmOperateLog.SpeedButton3Click(Sender: TObject);
begin
  Close;
end;

procedure TfrmOperateLog.FormCreate(Sender: TObject);
begin
  dtpBegin.Date := Date;
  dtpEnd.Date := Date;
end;

procedure TfrmOperateLog.btnSearchClick(Sender: TObject);
var
  SQL:string;
begin
  sql := '';
  if edtName.Text <> '' then
    SQL := 'where (O_Name like ''%' + edtName.Text + '%'')';

  if SQL = '' then
    SQL := ' where '
  else
    SQL := SQL + ' and ';

  SQl := 'Select * from Tab_S_operate ' +
    SQL + ' (O_Date > ''' + DateToStr(dtpBegin.Date) +
    ''') and (O_Date < ''' + DateToStr(dtpEnd.Date+1) + ''')';


  qryOperateLog.Close;
  qryOperateLog.SQL.Text := SQL;
  qryOperateLog.Open;
end;

procedure TfrmOperateLog.FormShow(Sender: TObject);
begin
  Self.Top := frmMain.Top + 91;
  Self.Height := frmMain.Height - 91;
  Self.Width := frmMain.Width-6;
  Self.Left := frmMain.Left+3;
end;

end.
